#include<iostream>
#include"commend.hpp"

int main()
{
    Fifo filo("./pipe");
    int rfd=open("pipe",O_RDONLY);
    if(rfd==-1)
    {
        perror("open");
        return 1;
    }
    while(true)
    {
        char buffer[1024];
        ssize_t ret=read(rfd,buffer,sizeof(buffer));
        cout<<ret<<endl;
        if(ret==0)
        {
            //读到文件结尾
            cout<<"At the end of the file, the server process exits"<<endl;
            break;
        }
        else if(ret>0)
        {
            buffer[ret]='\0';
            cout<<buffer<<endl;
        }
        else 
        {
            //出现错误
            perror("read");
            break;
        }
    }
    close(rfd);
    return 0;
}